package com.example.controller.test;

import com.alibaba.fastjson.JSON;

import com.example.annotation.common.ReqParam;
import com.example.pojo.vo.common.Result;
import com.example.request.test.QueryDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LiYuhang
 * @version 0.1
 * @application
 * @Date 2020/10/17 9:27
 */
@RestController
@RequestMapping(value = "/api")
@Slf4j
public class ApiTestController {

    /**
     * curl --location --request POST 'http://localhost:8085/api/query' \
     * --form 'name="李宇航"' \
     * --form 'deptId="2"' \
     * --form 'deptName="研发"'
     *
     *curl --location --request POST 'http://localhost:8085/api/query' \
     * --header 'Content-Type: application/json' \
     * --data-raw '{
     *   "name": "李宇航",
     *   "deptId": 7,
     *   "deptName": "申雪"
     * }'
     *
     * curl --location --request POST 'http://localhost:8085/api/query' \
     * --header 'Content-Type: application/x-www-form-urlencoded' \
     * --data-urlencode 'name=李宇航' \
     * --data-urlencode 'deptId=99' \
     * --data-urlencode 'deptName=技术部门'
     *
     * @param queryDto
     * @return
     */
    @RequestMapping(value = "/query")
    public Result query(@ReqParam QueryDto queryDto) {

        return Result.OK(queryDto);
    }


    @RequestMapping(value = "/query2")
    public String query2(@ReqParam QueryDto queryDto) {

        return JSON.toJSONString(queryDto);
    }

}
